import { http } from "@/plugins/axios";
import type { AxiosProgressEvent } from "axios";

export const UploadXZFile = "/api/anqing/UploadXingZheng";
export const DownloadXZFile = "/api/anqing/GetXingZhengMuBan";

export const UploadXSFile = "/api/anqing/UploadXingShi";
export const DownloadXSFile = "/api/anqing/GetXingShiMuBan";

export const Upload12345 = "/api/fangqing/Upload12345";
export const Download12345 = "/api/fangqing/Get12345MuBan";

export const Upload12389 = "/api/fangqing/Upload12389";
export const Download12389 = "/api/fangqing/Get12389MuBan";

export const UploadKongShen = "/api/fangqing/UploadKongShen";
export const DonwloadKongShen = "/api/fangqing/GetKongShenMuBan";

export const UploadEmail = "/api/fangqing/Uploadjuzhangxinxiang";
export const DonwloadEmail = "/api/fangqing/GetJuZhangXinXiangMuBan";

export const UploadMail = "/api/fangqing/UploadYouJiXinJian";
export const DonwloadMail = "/api/fangqing/GetYouJiXinJianMuBan";

class fileApi {
  //获取模板文件
  getFiles(url: string) {
    return http.fileRequest({
      url: url,
      method: "get",
      responseType: "blob",
    });
  }
  //上传文件
  uploadFiles(
    formData: FormData,
    url: string,
    onUploadProgress: (progressEvent: AxiosProgressEvent) => void
  ) {
    return http.request<string>({
      url: url,
      method: "post",
      data: formData,
      headers: {
        "Content-Type": "multipart/form-data",
      },
      onUploadProgress: onUploadProgress,
    });
  }
}
export default new fileApi();
